<template>
	<div>
		<el-dialog :title="$t('action.add')" width="70%" class="icon-dialog" :visible.sync="show" @open="open" :before-close="closeForm" append-to-body>
			<el-form :size="size" ref="form" :model="form" :rules="rules" :label-width="$store.getters.device !== 'mobile'?'16%':'90px'">
 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FOwnerType')" prop="FOwnerType">
							<el-input v-model="form.FOwnerType" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FOwnerType')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FOwnerNumber')" prop="FOwnerNumber">
							<el-input v-model="form.FOwnerNumber" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FOwnerNumber')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FOwnerName')" prop="FOwnerName">
							<el-input v-model="form.FOwnerName" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FOwnerName')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FStockNumber')" prop="FStockNumber">
							<el-input v-model="form.FStockNumber" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FStockNumber')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FStockName')" prop="FStockName">
							<el-input v-model="form.FStockName" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FStockName')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_Flot')" prop="Flot">
							<el-input v-model="form.Flot" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_Flot')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FProduceDate')" prop="FProduceDate">
							<el-input v-model="form.FProduceDate" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FProduceDate')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FExpiryDate')" prop="FExpiryDate">
							<el-input v-model="form.FExpiryDate" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FExpiryDate')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_Funit')" prop="Funit">
							<el-input v-model="form.Funit" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_Funit')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_Fqty')" prop="Fqty">
							<el-input v-model="form.Fqty" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_Fqty')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FMaterialNumber')" prop="FMaterialNumber">
							<el-input v-model="form.FMaterialNumber" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FMaterialNumber')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FMaterialName')" prop="FMaterialName">
							<el-input v-model="form.FMaterialName" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FMaterialName')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FUpdateTime')" prop="FUpdateTime">
							<el-input v-model="form.FUpdateTime" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FUpdateTime')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
	 				 <el-row >
					<el-col :span="24">
						<el-form-item :label="$t('field.Inventory_FStockStatus')" prop="FStockStatus">
							<el-input v-model="form.FStockStatus" autoComplete="off" clearable  :placeholder="$t('system.pleaseInput',{title:$t('field.Inventory_FStockStatus')})">
							</el-input>
						</el-form-item>
					</el-col>
				 </el-row>
				</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button :size="size" :loading="loading" type="primary" @click="submit" >
					<span v-if="!loading">{{$t('system.confirm')}}</span>
					<span v-else>{{$t('system.submitting')}}</span>
				</el-button>
				<el-button :size="size" @click="closeForm">{{$t('system.cancel')}}</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>
import { add } from '@/api/app/inventory'



export default {
	name:'inventoryadd',
	components: {

	},
	props: {
		show: {
			type: Boolean,
			default: false
		},
		size: {
			type: String,
			default: 'small'
		},
		querys:{
			type:Object,
		},
	},
	data(){
		return {
		    dialog:{
			},

			form: {
			   FOwnerType:'',
			   FOwnerNumber:'',
			   FOwnerName:'',
			   FStockNumber:'',
			   FStockName:'',
			   Flot:'',
			   FProduceDate:'',
			   FExpiryDate:'',
			   Funit:'',
			   Fqty:'',
			   FMaterialNumber:'',
			   FMaterialName:'',
			   FUpdateTime:'',
			   FStockStatus:'',
			},
		    initial:{},
			loading:false,
			rules: {
			}
		}
	},
	watch:{
		show(val){
			if(val){
			}
		}
	},
	methods: {
		open(){
		  if(this.querys){
		  }
		},
		submit(){
			this.$refs['form'].validate(valid => {
				if(valid) {
					this.loading = true
					add(this.form).then(res => {
						if(res.status == 200){
							this.$message({message: this.$t('system.success'), type: 'success'})
							this.$emit('refresh_list')
							this.closeForm()
						}
					}).catch(()=>{
						this.loading = false
					})
				}
			})
		},
		closeForm(){
			this.$emit('update:show', false)
			this.loading = false
			if (this.$refs['form']!==undefined) {
				this.$refs['form'].resetFields()
			}
		},
	}
}
</script>
<style scoped lang="scss">
@import '@/assets/scss/common.scss';
</style>
